package likou;

import java.util.Arrays;

/**
 * @author: Tangxz
 * @email: 1171702529@qq.com
 * @cate: 2021/11/29 10:16
 */
public class _786 {
    public static void main(String[] args) {
        System.out.println(Arrays.toString(kthSmallestPrimeFraction(new int[]{1,2,11,37,83,89},11)));
    }
    public static int[] kthSmallestPrimeFraction(int[] arr, int k) {
        int n = arr.length;
        int[] nows = new int[n];
        Arrays.fill(nows,n-1);
        Arrays.sort(arr);
        int left = 0,right = 1;
        int minIndex = 0;
        while(k>0){
            double min = 10000000.0;
            // 找到最小点
            for(int i=left;i<=right;i++){
                if(nows[i]==i) continue;
                double nowa = (double) arr[i] / arr[nows[i]];
                if(min > nowa){
                    min= nowa;
                    minIndex = i;
                }
            }
            k--;
            System.out.println(arr[minIndex]+"/"+arr[nows[minIndex]] +"="+ min);
            nows[minIndex]--;
            if(minIndex==right&&right<n-1){
                right++;
            }
        }
        return new int[]{arr[minIndex],arr[nows[minIndex]+1]};
    }
}
